package com.compass.mobile.presenters

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.leanback.widget.Presenter
import com.compass.mobile.R
import com.compass.mobile.models.InspectionReport

/**
 * Description：和医学
 * Date:2024/6/20 16:56
 */
class NuclearMedicineReportPresenter : Presenter() {

    override fun onCreateViewHolder(viewGroup: ViewGroup): ViewHolder {
        val view = LayoutInflater.from(viewGroup.context)
            .inflate(R.layout.item_my_report, viewGroup, false)
        return ViewHolder(view)
    }

    override fun onBindViewHolder(viewHolder: Presenter.ViewHolder, item: Any) {
        if (item is InspectionReport) {
            val vh = viewHolder as ViewHolder
            vh.orderId.text = "申请单号: ${item?.ACCESSIONNUMBER}"
            vh.patientId.text = "病  历  号: ${item?.PATIENTID}"
            vh.patientName.text = "患者姓名: ${item?.PATIENTNAMEC}"
            vh.patientSex.text = "患者性别: ${sexString(item?.PATIENTSEX)}"
            vh.studyDate.text = "检查事件: ${item?.STUDYDATE}"
            vh.writeDateTime.text = "检查事件: ${item?.WRITEDATETIME}"
            vh.doctorName.text = "报告医生: ${item?.REFERRINGPHYSICIAN}"
            vh.jianChaSuoJIan.text = "报告医生: ${item?.JIANCHASUOJIAN}"
            vh.JianChaJieLun.text = "报告医生: ${item?.JIANCHAJIELUN}"


        }
    }

    override fun onUnbindViewHolder(viewHolder: Presenter.ViewHolder) {

    }


    class ViewHolder(view: View) : Presenter.ViewHolder(view) {
        var orderId: TextView
        var patientId: TextView
        var patientName: TextView
        var patientSex: TextView
        var studyDate: TextView
        var writeDateTime: TextView
        var doctorName: TextView
        var jianChaSuoJIan: TextView
        var JianChaJieLun: TextView


        init {
            orderId = view.findViewById(R.id.orderId)
            patientId = view.findViewById(R.id.patientId)
            patientName = view.findViewById(R.id.patientName)
            patientSex = view.findViewById(R.id.patientSex)
            studyDate = view.findViewById(R.id.studyDate)
            writeDateTime = view.findViewById(R.id.writeDateTime)
            doctorName = view.findViewById(R.id.doctorName)
            jianChaSuoJIan = view.findViewById(R.id.jianChaSuoJIan)
            JianChaJieLun = view.findViewById(R.id.JianChaJieLun)


        }
    }

    private fun sexString(patientSex: String?): String {
        patientSex?.let {
            return if (it == "F") {
                "女"
            } else {
                "男"
            }
        } ?: kotlin.run {
            return "未知"
        }

    }
}